package com.veketor;
//Simplificaci�n: Rehacer pasando nombre de clase
// Debug.out(String texto, String nombreClase)
//{
// for (int i=0; i<lista
//  if (nombreDeClase pertenece a listaTrue o todo pertenece a listaTrue)
//     system.out.println()
//}

import java.sql.SQLException;
import java.util.Calendar;
import java.util.Vector;
//Static var Level 6--> show all; Static var level 0--> active=false;
//Higer value of the static level var. output more debuger info.
//dbOut force database error to output a debug.

public class Debug {
	static byte level;
	static boolean active;
	static boolean dbOut;
	static int forceOut=0;//magic number to force output.
	static Vector<String> classNameVector; 
	

	
	static void out(String text, boolean force)
	{
		if (force==true)
		{
			System.out.println(getTag()+text);
		}
		else
		{
			out(text);
		}
	}
	
	static void out(byte logLevel, String text)
	{
		if ((level>=logLevel && active) || logLevel==forceOut)
			{System.out.println(getTag()+text);}
	}
	
	static void out(int logLevel, String text)
	{
		out((byte) logLevel, text);
	}
	
	static void out(String text)
	{
		byte logLevel=3;
		out(logLevel,text);
	}
	
	static void out(SQLException e)
	{
		if (active || dbOut)
		{ 	e.printStackTrace();}
	}
	
	static void out(Exception e)
	{
		e.printStackTrace();
	}
	
	Debug()
	{
		level=3;
		active=true;
	}
	
	static void setLevel (byte logLevel)
	{
		level=logLevel;
		if (logLevel==0)
			on();
	}
	
	static void setLevel (int logLevel)
	{
		setLevel((byte)logLevel);
	}
	
	static void on()
	{
		active=true;
	}
	
	static void off()
	{
		active=false;
	}
	
	
	static void status()
	{
		System.out.println(getTag()+"Status level["+level+"]active["+active+"]dbOut["+dbOut+"]");
	}
	static boolean isActive()
	{
		return active;
	}
	
	static String getTag()
	{//TODO change calendar by date class
		Calendar c = Calendar.getInstance(); 
		int seconds = c.get(Calendar.SECOND);
		int day = c.get(Calendar.DAY_OF_MONTH);
		int month = c.get(Calendar.MONTH);
		int year = c.get(Calendar.YEAR);
		int hour = c.get(Calendar.HOUR_OF_DAY);
		int minutes = c.get(Calendar.MINUTE);
		return "["+day+"-"+month+"-"+year+" "+hour+":"+minutes+":"+seconds+"]";
	}
}
